package net.zdsoft.wpchat.support.action.system;

import javax.annotation.Resource;

import net.zdsoft.keel.cache.Cache;
import net.zdsoft.wpchat.android.client.BasicAction;

/**
 * 清除缓存模块Action
 * 
 * @author xuan
 * @version $Revision: 1.0 $, $Date: 2014-9-21 上午10:29:09 $
 */
public class CacheAction extends BasicAction {
    private static final long serialVersionUID = 2028187162349323941L;

    private String inputStream;

    @Resource
    private Cache<String, Object> cache;

    /**
     * 显示清理缓存页面
     * 
     * @return
     */
    public String clearCache() {
        return SUCCESS;
    }

    /**
     * 执行清理缓存
     * 
     * @return
     */
    public String doClearCache() {
        cache.put("key", "test");
        String cacheValue = (String) cache.get("key");

        cache.flushAll();
        Object flushValue = cache.get("key");

        if ("test".equals(cacheValue) && null == flushValue) {
            inputStream = getMessage("清理成功！");
            return SUCCESS;
        }

        inputStream = getError("清理失败！");
        return SUCCESS;
    }

    public String getInputStream() {
        return inputStream;
    }

    public void setInputStream(String inputStream) {
        this.inputStream = inputStream;
    }

}
